;;; haskell-settings.el --- 

;; Copyright (C) 2013  gww

;; Author: gww <gww@192.168.0.171>
;; Keywords: lisp

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; 

;;; Code:
(load-plugin "haskell-mode")
;;(load-file-ext "PLUGINS" "haskell-mode/haskell-site-file.el")
(require 'haskell-mode-autoloads)
(add-to-list 'Info-default-directory-list (get-env-path-ext "PLUGINS" "haskell-mode"))

(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)

(setq haskell-program-name "/usr/bin/ghci")

;;If you want to use different settings when you use Cygwin Emacs and NTEmacs, you can test the value of system-type:

;;(setq haskell-program-name (if (eq system-type 'cygwin) "/cygdrive/c/ghc/ghc-6.8.1/bin/ghcii.sh" "c:/ghc/ghc-6.8.1/bin/ghci.exe"))

(load-path-ext "PLUGINS" "ghc-mod/elisp")
(autoload 'ghc-init "ghc" nil t) 

;;(add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;;or
(add-hook 'haskell-mode-hook (lambda () (ghc-init) (flymake-mode)))

;;An example to specify GHC options:

(setq ghc-ghc-options '("-idir1" "-idir2"))
;;An example to specify HLint options:
(setq ghc-hlint-options '("--ignore=Use camelCase"))

;;---------------------------
;;key bind
(defun show-haskell-shell()
  (interactive)
  (setq temp-buffer-name (buffer-name (current-buffer)))
  (if (get-buffer "*haskell*")
      (switch-to-buffer-other-window "*haskell*")
    (switch-to-haskell))
  (switch-to-buffer-other-window temp-buffer-name)
  (show-output-window "*haskell*" t))

(defun hide-haskell-shell()
  (interactive)
  (other-window 1)
  (delete-other-windows))

;; Some Erlang customizations
(add-hook 'inferior-haskell-mode-hook
		  (lambda ()
			;;define C-c z
			(define-key inferior-haskell-mode-map (kbd "C-c z") 'hide-haskell-shell)))

(add-hook 'haskell-mode-hook
		  (lambda ()
			;;define C-c z
			(define-key haskell-mode-map (kbd "C-c z") 'show-haskell-shell)))



(provide 'mod-haskell)
;;; haskell-settings.el ends here

